package main

import (
	"fmt"
	"reflect"
)

type Person struct {
	name  string "姓名"
	age   int    "年龄"
	email string "邮箱"
}

type Fruit struct {
	title string
	count int
}

func main() {

	//
	//person := Person{"eissa", 18, "eirssa@gmail.com"}
	//
	//fmt.Println(person.name)

	var p1 = new(Person)
	fmt.Println(p1)
	p1.name = "eissa"
	p1.age = 18
	fmt.Println(p1)

	fmt.Println(p1.name)
	fmt.Println(p1.age)
	fmt.Println(*p1)

	p2 := Person{"ttao", 18, "eirssa@gmail.com"}

	fmt.Println(p2.name, p2.age, reflect.TypeOf(p2))

	p3 := &Person{"ttao", 18, "eirssa@gmail.com"}
	fmt.Println(p3)
	fmt.Println(p3.name, p3.age, reflect.TypeOf(p3))

	var userInfo = make(map[string]string)
	userInfo["name"] = "eissa"
	userInfo["age"] = "18"

	fmt.Println(userInfo)

	var map1 map[string]string
	map1 = userInfo
	fmt.Println(map1)

	var p4 Person

	p4.name = "eissa"
	p4.age = 18
	fmt.Println(p4)

	typeOf := reflect.TypeOf(p2)

	numField := typeOf.NumField()
	for i := 0; i < numField; i++ {
		field := typeOf.Field(i)
		fmt.Println(field)

	}

	title := "水果"
	cout := 5

	fruit := Fruit{title, cout}

	fmt.Println(fruit.title, fruit.count)

}
